// Name:            Forms
//
// Component:       `form`
//
// ========================================================================

// Variables
// ========================================================================
$form-control-round-border-radius: 200px !default;
$input-search-font-size: 16px !default;
$input-search-icon-width: $input-height !default;
$input-search-icon-line-height: $input-height !default;
$input-search-icon-z-index: $zindex-base !default;

// Component: Form
// ========================================================================

.form-control {
  // }
  box-sizing: border-box;
  height: $input-height; // for ie-s
  font-weight: $font-weight-light;
  border-color: $input-border; // add from---v3
  box-shadow: none; // for remove iphone-safari input box-shadow inset
  transition: box-shadow .25s linear, border .25s linear, color .25s linear, background-color .25s linear;
  // &:not(select) {//remove ios default style but select triangle'problem also
  -webkit-appearance: none;
  -moz-appearance: none;

  // Placeholder
  &::placeholder {
    font-weight: $font-weight-light;
  }
}

// Unified style for select
select.form-control {
  padding-right: 30px;
  background: $input-bg url() no-repeat center right;
}

select[multiple].form-control {
  padding-right: $input-btn-padding-x;
  background-image: none;
}

// for state focus
.form-control.focus, .form-control:focus {
  outline: 0;
}

textarea.form-control, select[multiple], select[size] {
  height: auto;
}

// size
//for ie-s
.form-control-sm {
  height: $input-height-sm;
}

.form-control-lg {
  height: $input-height-lg;
}

select.form-control-lg {
  &:not([size]):not([multiple]) {
    height: $input-height-lg;
  }
}

select.form-control-sm {
  &:not([size]):not([multiple]) {
    height: $input-height-sm;
  }
}

// form-control-label
.form-group {
  .form-control-label {
    padding: $input-btn-padding-y 0;

    &-lg {
      padding: $input-btn-padding-y-lg 0;
      font-size: $font-size-lg;
    }

    &-sm {
      padding: $input-btn-padding-y-sm 0;
      font-size: $font-size-sm;
    }
  }
}

// // states
// .has-success {
//   @include form-control-extend-validation($form-success-text, $form-success-text, $form-success-bg);
// }

// .has-warning {
//   @include form-control-extend-validation($form-warning-text, $form-warning-text, $form-warning-bg);
// }

// // .has-error class was replace by .has-danger(v4)
// .has-danger {
//   @include form-control-extend-validation($form-danger-text, $form-danger-text, $form-danger-bg);
// }

// form-group
.form-group {
  margin-bottom: $form-group-margin-bottom;

  &.has-feedback.no-label {
    .form-control-feedback {
      top: 0;
    }
  }

  &.has-feedback.left-feedback {
    .form-control-feedback {
      right: auto;
      left: 0;
    }

    .form-control {
      padding-right: 13px;
      padding-left: 50px;
    }
  }
}

// Modifier: `form-style`
// -------------------------
.form-control.square {
  border-radius: 0;
}

.form-control.round {
  border-radius: $form-control-round-border-radius;
}
// no-resize textarea
textarea.form-control.no-resize {
  resize: none;
}

// Modifier: `input-group-file`
// ----------------------------
.input-group-file {
  input[type="text"] {
    background-color: $input-bg;
  }

  .btn-file {
    position: relative;
    overflow: hidden;
    line-height: inherit;

    &.btn-outline {
      border: 1px solid $input-border;
      border-left: none;

      &:hover {
        border-left: none;
      }
    }

    .icon {
      margin: 0 3px;
      line-height: inherit;
    }

    input[type="file"] {
      position: absolute;
      top: 0;
      left: 0;
      display: block;
      min-width: 100%;
      min-height: 100%;
      text-align: 0;
      cursor: pointer;
      opacity: 0;
    }
  }
}

// Modifier: `help-block`
// "help-block" was replace by "text-help" in alpha2
// alpha3 instead of it with <small class="text-muted">
// Here retain it for some js plugin style it
// ----------------------
.text-help {
  display: block; // add v3
  margin-top: 7px;
  margin-bottom: 8px;
  color: lighten($text-color, 25%); // add v3

  .icon {
    margin: 0 5px;
  }
}

// Input Search
// ========================================================================
.input-search-close {
  color: $close-color;
  text-shadow: $close-text-shadow;
  opacity: .2;

  &.icon {
    font-size: inherit;
    line-height: inherit;
  }

  &:hover, &:focus {
    color: $close-color;
    text-decoration: none;
    cursor: pointer;
    opacity: .5;
  }
}

button.input-search-close {
  padding: 0;
  cursor: pointer;
  background: transparent;
  border: 0;
  -webkit-appearance: none;
}

.input-search {
  position: relative;

  .form-control {
    border-radius: $form-control-round-border-radius;
  }

  .input-search-icon, .input-search-close {
    position: absolute;
    top: 50%;
    z-index: $input-search-icon-z-index;
    width: $input-search-icon-width;
    transform: translateY(-50%);
  }

  .input-search-close {
    right: ($input-search-font-size / 2);
  }

  .input-search-icon + .form-control {
    padding-left: ($input-search-icon-width + ($padding-base-horizontal / 2));
  }

  .input-search-icon {
    left: ($input-search-font-size / 2);
    font-size: $input-search-font-size;
    color: $input-placeholder-color;
    text-align: center;
    pointer-events: none;
  }
}

.input-search-btn + .form-control {
  padding-right: 50px;
}

.input-search-btn {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  padding: 0 10px;
  background: transparent;
  border: none;
  border-radius: 0 $form-control-round-border-radius $form-control-round-border-radius 0;

  .icon {
    margin: 0 3px;
  }
}

.input-search-dark {
  .input-search-icon {
    color: $gray-500;
  }

  .form-control {
    background: $gray-100;
    box-shadow: none;

    &:focus {
      background-color: $input-focus-bg;
    }
  }
}

// Inline forms
// ========================================================================
.form-inline {
  @include media-breakpoint-down(sm) {
    .form-group {
      margin-right: 0;
    }
  }

  .form-group {
    margin-right: 20px;

    &:last-child {
      margin-right: 0;
    }
  }

  .form-control-label {
    margin-right: 5px;
  }
}

// Horizontal forms
// ========================================================================
.form-horizontal .form-control-label {
  padding-right: 15px;
  padding-left: 15px;
  font-size: $font-size-base;
}

@include media-breakpoint-up(md) {
  .form-horizontal .form-control-label {
    padding-top: 7px;
    margin-bottom: 0;
    text-align: right;
  }

  .form-horizontal {
    .form-control-lg {
      padding-top: 11px;
      font-size: 18px;
    }

    .form-control-sm {
      padding-top: 7px;
      font-size: 12px;
    }
  }
}

//for remove ie11 Pseudo class text
input::-ms-clear {
  display: none;
  width: 0;
  height: 0;
}
